public with sharing class NotesExtension {
public List<Notes__c> LeadNotes{get;set;}
    ID NotesRecordTypeID = RecordTypeHelper.GetRecordTypeIdByDevName('Notes__c', 'CXG_Notes_Recordtype');   
    public NotesExtension(ApexPages.StandardController controller) {
    if(ApexPages.currentPage().getParameters().get('type') == 'lead' ){
    
        LeadNotes = [select id,Name,Notes__c,Disposition__c,CreatedDate from Notes__c 
                     where Lead__c =:ApexPages.currentPage().getParameters().get('leadid') AND RecordTypeId!=:NotesRecordTypeID 
                     order by CreatedDate Desc];}
   
    else if(ApexPages.currentPage().getParameters().get('type') == 'opty' ){
    
            LeadNotes = [select id,Name,Notes__c,Disposition__c,CreatedDate from Notes__c 
                        where opportunity__c =:ApexPages.currentPage().getParameters().get('oppid') AND RecordTypeId!=:NotesRecordTypeID
                        order by CreatedDate Desc];}
    else if(ApexPages.currentPage().getParameters().get('type') == 'accnt' ){
    
            LeadNotes = [select id,Name,Notes__c,Disposition__c,CreatedDate from Notes__c 
                        where account__c =:ApexPages.currentPage().getParameters().get('accid') AND RecordTypeId!=:NotesRecordTypeID
                        order by CreatedDate Desc];}                   
                        

    }


public static testMethod void testNotexExtension()
{
Lead ld = new Lead(Company ='Test10 Demo',FirstName='John10',LastName='Smith10',Phone='1089898989',Disposition__c='Ready for Order');
Insert ld;

Account accObj = new Account(Name='Test Account45');
insert accObj;
Opportunity opp = new Opportunity();
opp.AccountId= accObj.Id;
opp.Name='Test Opp';
opp.LeadSource='Internet';
Date curr = Date.today();
opp.CloseDate=curr;
opp.StageName='New';
//opp.Notes__c='testcoverage';
insert opp;
Notes__c callnotes = new Notes__c();
callnotes.Lead__c=ld.Id;
callnotes.Disposition__c='Called';
callnotes.Opportunity__c=opp.Id;
callnotes.account__c=accObj.Id;
callnotes.Notes__c='testing';
insert callnotes;

ApexPages.CurrentPage().getParameters().put('type','lead'); 
ApexPages.CurrentPage().getParameters().put('leadid',ld.id); 
ApexPages.StandardController thecontroller  = new ApexPages.StandardController(callnotes);
NotesExtension objnotes = new NotesExtension(thecontroller);

ApexPages.CurrentPage().getParameters().put('type','opty');
ApexPages.CurrentPage().getParameters().put('oppid',opp.Id);
ApexPages.StandardController thecontroller1  = new ApexPages.StandardController(callnotes);
NotesExtension objnotes1 = new NotesExtension(thecontroller1);

ApexPages.CurrentPage().getParameters().put('type','accnt');     
ApexPages.CurrentPage().getParameters().put('accid',accObj.Id);   
ApexPages.StandardController thecontroller2  = new ApexPages.StandardController(callnotes);
NotesExtension objnotes2 = new NotesExtension(thecontroller2);

}
  
}